<template>
	<view class="content">
		<u-navbar class="content_navbar" title="系统消息"></u-navbar>

		<z-paging ref="paging" :fixed="false" :height="height" v-model="dataList" @query="queryList">
			<view class="content_item" v-for="item in dataList" :key="item.id" @click="$u.throttle(toDetail(item), 2000)">
				<view class="u-flex u-row-between">
					<view class="u-font-32 u-font-weight">
						{{item.type_text}}
					</view>
					<view class="u-font-13" style="color: #7d7c7c">
						{{$u.timeFormat(item.addtime,'yyyy-mm-dd hh:MM')}}
					</view>
				</view>
				<view class="u-m-t-10  " style="color: #6b6a6a;">
					{{item.content}}
				</view>
				<view class="u-m-t-10" style="color: #00D075;" v-if="item.inner_link">
					点击查看详情
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue"
	import {
		onReady
	} from '@dcloudio/uni-app'
	const height = ref('')
	const paging = ref(null)
	let dataList = ref([])
	onReady(() => {
		getListHeight()
	})
	// 获取列表展示高度
	const getListHeight = async () => {
		let res = await uni.$u.getRect('.content_navbar');
		if (res) {
			height.value = (uni.$u.sys().windowHeight - res.height) + 'px'
		}
	}
	// 根据 utype、inner_link 跳转不同的详情页
	const toDetail = (item) => {
		// 1-企业端  2-求职端
		if (uni.getStorageSync('utype') == 1) {
			if (uni.getStorageSync('next_code') == 50004) {
				uni.$u.route('pages/pagesPersonal/set/auth/auth')
				return
			}
			switch (item.inner_link) {
				case 'resumeshow':
					uni.$u.route('/pages/pagesHome/detailPages/resume', {
						id: item.inner_link_params
					})
					break
				case 'job_manage':
					// 职位管理
					uni.$u.route('pages/pagesPersonal/job/job')
					break
				case 'company_index':
					uni.$u.route({
						type: 'tab',
						url: 'pages/personal/index'
					})
					break
				case 'company_auth':
					// 认证页面
					uni.$u.route('pages/pagesPersonal/set/auth/auth')
					break
				case 'ordershow':
					// 订单
					uni.$u.route('pages/pagesPersonal/integral/serve/serve')
					break
				case 'im':
					uni.$u.route('pages/pagesMessage/list')
					break
				case 'service':
					uni.$u.route('/member/order/add/common?type=service')
					break
				case 'coupon':
					// 优惠券
					uni.$u.route('/member/company/coupon')
					break
				case 'service_setmeal':
					// 购买服务
					uni.$u.route('/member/order/add/common?type=setmeal')
					break
				case 'interview_list':
					uni.$u.route('pages/pagesMessage/interview/interview')
					break
				case 'recommend_resumelist':
					uni.$u.route({
						type: 'tab',
						url: 'pages/home/home'
					})
					break
				default:
					break
			}
		} else {
			switch (item.inner_link) {
				case 'companyshow':
					uni.$u.route('pages/pagesHome/detailPages/company', {
						id: item.inner_link_params,
						show: false
					})
					break
				case 'interview_list':
					uni.$u.route('pages/pagesMessage/interview/interview')
					break
				case 'apply_list':
					uni.$u.route('pages/pagesPersonal/deliver/deliver')
					break
				case 'joblist':
					uni.$u.route({
						type: 'tab',
						url: 'pages/home/home'
					})
					break
				case 'resumeedit':
					uni.$u.route('pages/pagesPersonal/myResume/myResume')
					break
				case 'im':
					uni.$u.route('pages/pagesMessage/list')
					break
				case 'ordershow':
					uni.$u.route('pages/pagesPersonal/integral/serve/serve')
					break
				case 'recommend_joblist':
					uni.$u.route({
						type: 'tab',
						url: 'pages/home/home'
					})
					break
				default:
					break
			}
		}
	}
	// 获取系统消息列表
	const queryList = async (pageNo, pageSize) => {
		let params = {
			page: pageNo,
			pagesize: pageSize,
		}
		let res = await uni.$u.api.getSystemMsgList({
			params
		})
		if (ref) {
			paging.value.complete(res.items)
		}
	}
</script>
<style>
	page {
		background-color: #F6F6F6;
	}
</style>
<style scoped lang="scss">
	.content {
		&_item {
			width: 90vw;
			background-color: #fff;
			margin: 20rpx auto;
			padding: 40rpx 34rpx;
			font-size: 28rpx;
			color: #101010;
		}
	}
</style>